import 'package:flutter/material.dart';
import 'package:lai_zhan/common/style/AppStyle.dart';

//输入框
class TextInput extends StatelessWidget {


  TextEditingController controller;
  ValueChanged<String> onChange;
  Icon icon;
  String hintText;
  String errorText;
  String labelText;
  EdgeInsetsGeometry padding;
  EdgeInsetsGeometry margin;
  bool obscureText;
  InputBorder inputBorder;
  TextInputType keyboardType;
  double fontSize;
  TextAlign textAlign = TextAlign.left ;
  Color textColor;

  TextInput(
      {this.controller,
      this.onChange,
      this.icon,
      this.hintText,
      this.padding,
      this.margin,
      this.obscureText = false,
      this.errorText,
      this.labelText,
      this.inputBorder,
      this.keyboardType,
      this.fontSize = 20,
      this.textAlign = TextAlign.left,
      this.textColor = Colors.black});

  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return new Container(
        padding: padding,
        margin: margin,
        child: new Theme(
          data: ThemeData(
              primaryColor: Color(AppColors.primaryColor), hintColor: Colors.grey),
          child: new TextField(
            controller: controller,
            onChanged: onChange,
            obscureText: obscureText,
            cursorColor: Color(AppColors.primaryColor),
            keyboardType: keyboardType,
            style: TextStyle(fontSize: fontSize,color: textColor),
            textAlign: textAlign,
            decoration: InputDecoration(
              border: inputBorder,
              labelText: labelText == null ? null : labelText,
              fillColor: Color(AppColors.primaryColor),
              icon: icon == null ? null : icon,
              errorText: errorText == null ? null :errorText,
              hintText: hintText==null?null:hintText,
            ),
          ),
        ));
  }
}
